package com.hoyo.domain;

import java.util.List;
import java.util.Set;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ModuleMapper {

	/**
	 * 获取该人的权限模块
	 * @param userId
	 * @return
	 */
	@Select(value="select e.* from user_role b left join role c on b.role_id=c.id left join role_module d on c.id=d.role_id left join module e on d.module_id=e.id where b.user_id=#{userId}")
	List<ModuleInfo> findModuleByUserId(int userId)throws Exception;
	
	@Select("select role.role_name from user_role ur left join role on role.id=ur.role_id left join user on user.id=ur.user_id where (user.phone=#{0} or user.email=#{0})")
	Set<String> findRolesByAccount(String account);
	
	@Select("select * from module")
	List<ModuleInfo> findAllModules();
}
